package cn.gs.web;

import cn.gs.domain.Customer;
import cn.gs.service.CustomerService;
import cn.gs.service.CustomerServiceImpl;

import java.util.List;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class CustomerAction extends ActionSupport implements ModelDriven<Customer> {

	private Customer customer = new Customer();
	private CustomerService customerService;
	private List<Customer> list;
	private String cust_id;
	private String pageCount;
	private String page;
	private String pCount;
	
	

	public String add() {
		customerService.add(customer);
		return "success";
	}
	
	public String pag() {
		if(page==null){
			page="1";
		}
		int i=Integer.valueOf(page);
		list = customerService.paging(i);		
		
	
		ActionContext.getContext().put("pCount",pCount);
		return "pagsuc";		
	}
	
	
	
	public String selectByID() {
	customer= customerService.selectByID(customer.getCust_id());
	ActionContext.getContext().put("customer", customer);
	return "selIDsuc";
	}
	
	public  String update() {
		customerService.update(customer);
		return "updsuc";		
	}
	
	public String delete() {
		customerService.del(customer.getCust_id());
		return "delsuc";
	}
	
	public String selName() {
		try {
			list=customerService.selName(customer.getCust_name());
			return "selnamesuc";
		} catch (Exception e) {
			return "selnamedef";
		}
		
		
	}

	public Customer getModel() {
		return customer;
	}

	public CustomerService getCustomerService() {
		return customerService;
	}

	public void setCustomerService(CustomerService customerService) {
		this.customerService = customerService;
	}

	public List<Customer> getList() {
		return list;
	}

	public void setList(List<Customer> list) {
		this.list = list;
	}

	public String getCust_id() {
		return cust_id;
	}

	public void setCust_id(String cust_id) {
		this.cust_id = cust_id;
	}

	public String getPageCount() {
		return pageCount;
	}

	public void setPageCount(String pageCount) {
		this.pageCount = pageCount;
	}

	public String getPage() {
		return page;
	}


	public void setPage(String page) {
		this.page = page;
	}

	public String getpCount() {
		return pCount;
	}

	public void setpCount(String pCount) {
		this.pCount = pCount;
	}

	
	
}
